<button class="btn btn-info btn-xs" data-toggle="modal" data-target="#customerShare{{ $id }}">转赠</button>

<div class="modal fade" id="customerShare{{ $id }}" tabindex="-1" role="dialog" aria-labelledby="customerShare" aria-hidden="true">
    <div class="modal-dialog modal-xs">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="font-size: 36px;">&times;</button>
                <h4 class="modal-title" id="myModalLabel">转赠</h4>
            </div>
            <div class="modal-body">
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">资源接收人</label>
                    <select class="form-select form-control" name="shareId{{ $id }}">
                        @foreach($data as $k => $v)
                            <option value="{{ $v['user_id'] }}">{{ $v['name'] }}</option>
                        @endforeach
                    </select>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" onclick="customerShare({{ $id }})">提交</button>
            </div>
        </div>
    </div>
</div>
<script>
    function customerShare(id)
    {
        ajaxPostFunc('/admin/ajax/customerShare', {
            id: id,
            share: $("select[name='shareId"+id+"']").val(),
            _token: $.admin.token
        }, {}, res => {
            console.log(res);
            window.location.reload();
        });
    }
</script>
